<template>
    <div class="App">
        <div class="Title">一起健身吧！</div>
        <input class="input1" placeholder="输入admin" v-model="user" />
        <input class="input2" placeholder="输入123456" type="password" v-model="password" />
        <button class="botton1" @click="GotoHome">登录</button>
        <div class="Other1">其他登陆方式：</div>
        <img :src="Img1" alt="" class="Other2" @click="GotoHandset">
        <img :src="Img2" alt="" class="Other3" @click="getProfile">{{ msg }}
    </div>
</template>

<script setup lang="ts" name="LoginPage">
import Img1 from "../yyp-component/Imgs/10.png"
import Img2 from "../yyp-component/Imgs/11.png"
import router from "@/router";
import { ref } from "vue"
const user = ref("")
const password = ref("")
import axios, { fetchData } from "../../stores/request";

const msg = ref("")

const getProfile = async () => {
    const data = await fetchData("/profile")
    msg.value = data
}

const GotoHome = async () => {
    sessionStorage.setItem("用户", user.value + "用户")
    const {data} = await axios.post("/login",{
        user:user.value,
        password:password.value
    });
    msg.value = data
    
    router.push("/home/index")
}

const GotoHandset = () => {
    router.push("/handset")
}

</script>

<style scoped>
.App {
    position: relative;
    left: 0px;
    top: 0px;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.61);
}

.Title {
    position: absolute;
    left: 54px;
    top: 161px;
    width: 300px;
    height: 72px;
    line-height: 72px;
    color: rgba(117, 187, 117, 1);
    font-size: 48px;
    text-align: center;
}

.input1 {
    position: absolute;
    left: 39px;
    top: 264px;
    width: 297px;
    height: 45px;
    line-height: 20px;
    border-radius: 20px;
    background-color: rgba(255, 255, 255, 1);
    color: rgba(136, 136, 136, 1);
    font-size: 16px;
    text-align: center;
    font-family: Microsoft Yahei;
    border: 1px solid rgba(187, 187, 187, 1);
}

.input2 {
    position: absolute;
    left: 39px;
    top: 326px;
    width: 297px;
    height: 45px;
    line-height: 20px;
    border-radius: 20px;
    background-color: rgba(255, 255, 255, 1);
    color: rgba(136, 136, 136, 1);
    font-size: 16px;
    text-align: center;
    font-family: Microsoft Yahei;
    border: 1px solid rgba(187, 187, 187, 1);
}

.botton1 {
    position: absolute;
    left: 39px;
    top: 388px;
    width: 297px;
    height: 45px;
    line-height: 20px;
    background-color: #75BB75;
    color: white;
    font-size: 14px;
    text-align: center;
    font-family: Roboto;
    border: 1px solid rgba(255, 255, 255, 0);
    border-radius: 20px
}

.Other1 {
    position: absolute;
    left: 59px;
    top: 456px;
    width: 112px;
    height: 23px;
    line-height: 23px;
    color: rgba(64, 64, 64, 1);
    font-size: 16px;
    text-align: left;
    font-family: PingFangSC-regular;
}

.Other2 {
    position: absolute;
    left: 128px;
    top: 501px;
    width: 32px;
    height: 32px;
    background-color: rgba(63, 81, 181, 1);
}

.Other3 {
    position: absolute;
    left: 223px;
    top: 501px;
    width: 32px;
    height: 32px;
    background-color: rgba(37, 155, 36, 1);
}
</style>